<? 
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); 
header("Cache-Control: no-cache, must-revalidate" ); 
header("Pragma: no-cache" );
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
	<meta name="author" content="Jeevan" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="<?=base_url()?>css/style.css" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="<?=base_url()?>css/accmenu.css" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="<?=base_url()?>css/content.css" />
    <link rel="stylesheet" media="screen,projection" type="text/css" href="<?=base_url()?>css/datagrid.css" />
    <script src="<?=base_url()?>js/jquery-1.6.4.min.js" type="text/javascript"></script>
    <script src="<?=base_url()?>js/jquery.validate.js" type="text/javascript"></script>
    <script src="<?=base_url()?>js/additional-methods.js" type="text/javascript"></script>
    <script src="<?=base_url()?>js/jquery.validate.messages.js" type="text/javascript"></script>
    <script src="<?=base_url()?>js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
    <link href="<?=base_url()?>css/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
    <link type="text/css" href="<?=base_url()?>css/ui.multiselect.css" rel="stylesheet" />
    <script type="text/javascript" src="<?=base_url()?>js/ui.multiselect.js"></script>
    <!-- Uploadify Library-->
    <link rel="stylesheet" media="screen,projection" type="text/css" href="<?=base_url()?>uploadify/uploadify.css" />
    <script src="<?=base_url()?>uploadify/swfobject.js" type="text/javascript"></script>
    <script src="<?=base_url()?>uploadify/jquery.uploadify.v2.1.4.min.js" type="text/javascript"></script>
    <!-- Jcrop Library-->
    <link rel="stylesheet" media="screen,projection" type="text/css" href="<?=base_url()?>jcrop/css/jquery.Jcrop.css" />
    <script src="<?=base_url()?>jcrop/js/jquery.Jcrop.min.js" type="text/javascript"></script>
    <!-- Fancybox Library-->
    <link rel="stylesheet" media="screen,projection" type="text/css" href="<?=base_url()?>fancybox/jquery.fancybox-1.3.4.css" />
    <script src="<?=base_url()?>fancybox/jquery.fancybox-1.3.4.js" type="text/javascript"></script>
    <?
    if(isset($enablejhtml) && $enablejhtml == true) {
    ?>
    <script type="text/javascript" src="<?=base_url()?>js/jHtmlArea-0.7.0.js"></script>
    <link rel="Stylesheet" type="text/css" href="<?=base_url()?>css/jHtmlArea.css" /> 
    <?        
    }
    ?>
    <script src="<?=base_url()?>js/chosen.jquery.min.js" type="text/javascript"></script>
    <link href="<?=base_url()?>css/chosen.css" rel="stylesheet" type="text/css" />
    <script src="<?=base_url()?>js/fn.js" type="text/javascript"></script>
    <script type="text/javascript">
         
        $(document).ready( function() {
            $(window).resize( function() {
                setWinSize();
            });
            setWinSize();
            
            $( "#firstpane" ).accordion({
    			collapsible: true,
                autoHeight : false
    		});
            
            var tab_array = new Object();
            var tab_counter = 2;
            var tab_content = "";
            var tab_url = "";
            var tab_id_url_map = new Object();
            
            var loading_msg = '<div id="loadingdiv"><div class="centerdiv"><img src="/images/loading2.gif" /></div></div>';
            
            // tabs init with a custom tab template and an "add" callback filling in the content
            var $tabs = $("#contenttabs").tabs({
    			tabTemplate: "<li><a href='#{href}'>#{label}</a> <span class='ui-icon ui-icon-close'>Remove Tab</span></li>",
    			add: function( event, ui ) {
    				var tab_content = loading_msg;
    				$( ui.panel ).append( tab_content );
                    $tabs.tabs("select",'#'+ui.panel.id);
                    $(ui).attr('taburl',tab_url);
                    $( ui.panel ).load(tab_url, function(response, status, xhr) {
                        if (status == "error") {
                            var errormsg = "<div style='width: 500px; margin: 100px auto; color: red; font-weight: bold;'>Sorry but there was an error: "+xhr.status + " " + xhr.statusText+"<br/>Contact administrator.</div>";
                            $( ui.panel ).html(errormsg);
                        }
                    });
                    tab_array[tab_url] = ui;    // Save tab with ui ref.
                    tab_id_url_map[ui.panel.id] = tab_url;
                    
                    $navheight = $("#contenttabs ul.ui-tabs-nav").height();
                    $colminheight = getColMinHeight();
                    $("#contenttabs div.ui-tabs-panel").css("height",($colminheight-$navheight-15)+"px"); 
                    
    			},
                remove: function(event, ui) {
                    var taburl = tab_id_url_map[ui.panel.id];
                    tab_array[taburl] = "";
                    tab_id_url_map[ui.panel.id] = "";
                    
                    $navheight = $("#contenttabs ul.ui-tabs-nav").height();
                    $colminheight = getColMinHeight();
                    $("#contenttabs div.ui-tabs-panel").css("height",($colminheight-$navheight-15)+"px");
                }
            });
            
            // actual addTab function: adds new tab using the title input from the form above
    		function addWinTab(tabtitle, taburl) {
                if(typeof(tab_array[taburl]) != 'undefined' && tab_array[taburl] != '') {
                    var tab_content = loading_msg;
                    ui = tab_array[taburl];
    				$( ui.panel ).html(tab_content);
                    $tabs.tabs("select",'#'+ui.panel.id);
                    $( ui.panel ).load(taburl, function(response, status, xhr) {
                        if (status == "error") {
                            var errormsg = "<div style='width: 500px; margin: 100px auto; color: red; font-weight: bold;'>Sorry but there was an error: "+xhr.status + " " + xhr.statusText+"<br/>Contact administrator.</div>";
                            $( ui.panel ).html(errormsg);
                        }
                    });
                } else {
        			var tab_title = tabtitle;
                    tab_url = taburl;
        			$tabs.tabs( "add", "#tabs-" + tab_counter, tab_title );
        			tab_counter++;
                }
    		}
            
            addMyWin = addWinTab;
    
    		// close icon: removing the tab on click
    		// note: closable tabs gonna be an option in the future - see http://dev.jqueryui.com/ticket/3924
    		$( "#contenttabs span.ui-icon-close" ).live( "click", function() {
    			var index = $( "li", $tabs ).index( $( this ).parent() );
    			$tabs.tabs( "remove", index );
    		});
            
            $('a.menuitem').click(function () {
                //alert($(this).attr('href'));
                $('a.menuitem').removeClass("selected");
                $(this).addClass("selected");
                addWinTab($(this).attr('title'),$(this).attr('href'));
                /*
                $('#content').html('<div id="loadingdiv"><div class="centerdiv"><img src="/images/loading2.gif" /></div></div>');
                $("#content").load($(this).attr('href'));
                */
                return false;
            });
                    
        });
        
        var addMyWin = null;
        
        function setWinSize() {
            $colminheight = getColMinHeight();
            if($colminheight > $minheight) {
                $("#left").css("height",$colminheight+"px");
                $("#contentcontainer").css("height",($colminheight)+"px");  // Subtract #contetn padding
                $("#contenttabs").css("height",($colminheight-6)+"px");      
            } else {
                $("#left").css("height",$minheight+"px");
                $("#contentcontainer").css("height",($minheight)+"px");  // Subtract #contetn padding
                $("#contenttabs").css("height",($colminheight-6)+"px");
            }
            
            if($(".datagridcontainer")) {
                $(".datagridcontainer").css("width",(800)+'px');
                $(".datagridcontainer").css("width",($("#contentcontainer").width()-20)+'px');
            }
        }
        
        function getColMinHeight() {
            $minheight = 500;
            $winheight = $(window).height();
            $topheight = $("#top").height();
            $footerhirght = $("#foot").height();
            $colminheight = $winheight - $topheight - $footerhirght;
            $colminheight = $colminheight - 8; //  Subtract #mid margin
            return $colminheight;
        }
        
        function placeError(error, element) {
            var errorplace = element.parent().next();
            error.appendTo(errorplace);
        }        
        
    </script>
    <style>
    	#contenttabs li .ui-icon-close { float: left; margin: 0.4em 0.2em 0 0; cursor: pointer; }
	</style>
    <? $user = $this->session->userdata('user'); ?>
	<title><?=lang("main_title")?></title>
</head>

<body>

    <div id="main">
    
        <div id="top">
            <div id="title">
                <strong><?=lang("product_name")?></strong> - <?=lang("product_name_2")?>
            </div>
            <div id="subtitle">
                <?=lang("control_panel")?>
            </div>
            <div id="user_area">
                User: 
                <strong><?=$user['name']?></strong>
                <strong>
                    <a href="<?=base_url('logout')?>"><?=lang("logout")?></a>
                </strong>
            </div>
        </div>
        
        <div id="mid">
            <table cellspacing="2" cellpadding="0" border="0">
                <tr>
                    <td id="left">
                        <? 
						$this->load->view('elements/sidenav');
						?>
                    </td>
                    <td id="content">           